package com.aaa.mythread;

public class MyThread1 extends Thread{

    private String name;

    public MyThread1(String name) {
        this.name = name;
    }

    @Override
    public void run() {

        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //  业务
        for (int i = 0; i < 5; i++) {
            System.out.println(name+":数字是:"+i);
        }

    }


    public static void main(String[] args) {
        // 启动线程的唯一方式就是  调用start方法
        MyThread1 myThread1 = new MyThread1("线程1");
        myThread1.start();
        MyThread1 myThread2 = new MyThread1("线程2");
        myThread2.start();
        MyThread1 myThread3 = new MyThread1("线程3");
        // 启动线程
        myThread3.start();
    }
}
